package com.org.khtn.data;

import java.util.Vector;

/**
 * Lá»›p pojo Ä‘á»ƒ Ã¡nh xáº¡ xuá»‘ng file json
 * 
 * @author Son
 * 
 */
public class DataTableDefination {
	private String varName;
	private String type;
	private String tableName;
	private String[] pk;

	public DataTableDefination(String TableName, String VarName, String Type) {
		varName = VarName;
		type = Type;
		tableName = TableName;
	}

	public DataTableDefination(String TableName, String VarName, String Type,
			String Pk[]) {
		varName = VarName;
		type = Type;
		tableName = TableName;
		pk = Pk;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return "varName: " + varName + " type: " + type;
	}

	public String getVarName() {
		return varName;
	}

	public void setVarName(String VarName) {
		varName = VarName;
	}

	public void setTypes(String Types) {
		type = Types;
	}

	public String getTypes() {
		return type;
	}

	public Vector<String> getPk() {
		if (pk == null)
			return null;
		int length = pk.length;
		Vector<String> result = new Vector<>();
		for (int i = 0; i < length; i++) {
			result.add(pk[i]);
		}
		return result;
	}

	public void setPk(Vector<String> keys) {
		// Tao sửa chỗ này
	
		if (keys == null) {
			pk = null;
			return;
		}
		int length = keys.size();
		pk = new String[length];
		for (int i = 0; i < length; i++) {
			pk[i] = (String) keys.get(i);
		}

	}

	public String getTableName() {
		return tableName;
	}

	public DataTableDefination getObject(String TableName) {
		if (tableName.equalsIgnoreCase(TableName))
			return this;
		return null;
	}

}
